package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteOfferInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Objects;

/**
 * @Description 赠送期限属性处理
 * @Author deng.gang
 * @Date 2021/9/29 3:57 下午
 */
public class GiftPeriodAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Autowired
    private IQuerySceneInstService querySceneInstService;

    @Override
    public void onShow(KiteAttr attr, KiteInst inst, AttrData data) {
        KiteOfferInst mainOfferInst = querySceneInstService.getMainOfferInst(data.getSceneInstId());
        if (Objects.nonNull(mainOfferInst)) {
            String offerId = mainOfferInst.getOfferId();
            if (KiteStringUtils.equalsAny(offerId, "50040705", "50040704")) {
                attr.setShowType(KeyConsts.PROD_ATTR_SHOW_TYPE_E);
            }
        }
        super.onShow(attr, inst, data);
    }
}
